package com.yangrong.webcrawler.controller;

import com.yangrong.webcrawler.schedule.NewsPuller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;


/**
 * 微鲸新闻列表
 *
 * @author yangrong
 * @email 455833224@qq.com
 * @date 2020-08-26 15:21:07
 */
@RestController
// 开启定时任务
@EnableScheduling
@RequestMapping("/webcrawler")
public class NewsController {

    @Autowired
    @Qualifier("newsPullerImpl")
    private NewsPuller newsPullerImpl;

    @GetMapping("/pull/news")
    public void pullWeiJingNews() {
        newsPullerImpl.pullNews();
    }

    // 每天8点取52Hz值
    @Scheduled(cron = "0 0 8 ? * *")
    public void getHz() {
        newsPullerImpl.getHz();
    }

}
